<%@page pageEncoding="UTF-8" isELIgnored="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="f" uri="http://www.slim3.org/functions"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>todo Index</title>
<link rel="stylesheet" type="text/css" href="/css/global.css" />
<script type="text/javascript" src="/javascripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/javascripts/todo.js"></script>
</head>
<body>
${loginInfo}
<a href="${f:url('')}">${f:url('')}</a>
<form action="/member/todo/add" method="post">
<input type="hidden" name="key" />
<input type="text" ${f:text("dueDate")} class="${f:errorClass('dueDate', 'error')}" />
<input type="text" ${f:text("category")} class="${f:errorClass('category', 'error')}" />
<input type="text" ${f:text("content")} class="${f:errorClass('content', 'error')}" />
<input type="button" value="追加" onclick="Todo.save();" />
</form>
<div class="">
${f:h(errors.dueDate)}
${f:h(errors.category)}
${f:h(errors.content)}
</div>
一覧
<table border="1" id="id_task_list">
  <tr>
    <td width="50px">状態</td>
    <td width="120px">期限</td>
    <td width="120px">カテゴリ</td>
    <td width="200px">内容</td>
    <td colspan="2">&nbsp;</td>
  </tr>
<c:forEach var="e" items="${taskList}">
  <tr id="row_id_${e.key}">
    <td>
      <a href="done?key=${e.key}&done=t">done</a>
    </td>
    <td>
      <fmt:formatDate value="${e.dueDate}" pattern="yyyy/MM/dd" />
    </td>
    <td>${f:h(e.category.name)}</td>
    <td>${f:h(e.content)}</td>
    <c:set var="editUrl" value="edit?key=${e.key}"/>
    <c:set var="deleteUrl" value="delete?key=${e.key}"/>
    <td><a href="#" onclick="return Todo.search('${e.key}');">Edit</a></td>
    <td><a href="${f:url(deleteUrl)}" onclick="return confirm('delete OK?')">Delete</a></td>
  </tr>
</c:forEach>
<c:forEach var="e" items="${doneList}">
  <tr style="background-color: #dddddd;" id="row_id_${e.key}">
    <td>
      <a href="done?key=${e.key}&done=f">戻す</a>
    <td>
      <fmt:formatDate value="${e.dueDate}" pattern="yyyy/MM/dd" />
    </td>
    <td>${f:h(e.content)}</td>
    <c:set var="deleteUrl" value="delete?key=${e.key}"/>
    <td colspan="2">
      <a href="${f:url(deleteUrl)}" onclick="return confirm('delete OK?')">Delete</a>
    </td>
  </tr>
</c:forEach>
</table>

<c:forEach var="e" items="${categories}">
${e.name}<br />
</c:forEach>
</body>
</html>
